<template>
	<view class="addEdit_box">
		<view class="add_box" >
			<form @submit="submit" @reset="formReset">
					<view style="display: inline;">
						<view class="uni-form-item uni-column form_row">
							<label  class="form_row_lable">牌号:</label>
							<input  name="ph" class="form_row_input" placeholder="请输入" />
						</view>
						
						<view class="uni-form-item uni-column form_row">
							<label  class="form_row_lable">包内铁水成分标准铜%:</label>
							<input type="number" name="cuBz" class="form_row_input" placeholder="请输入"/>
						</view>
						
						<view class="uni-form-item uni-column form_row" >
							<label  class="form_row_lable">电炉铁水成分标准锡%:</label>
							<input type="number" name="snBz" class="form_row_input" placeholder="请输入"/>
						</view>
						
						<view class="uni-form-item uni-column form_row">
							<label class="form_row_lable">包内铁水成分标准锰%:</label>
							<input type="number" name="mnBz" class="form_row_input" placeholder="请输入"/>
						</view>
						<view class="uni-form-item uni-column form_row" >
							<label  class="form_row_lable">铜粒铜含量%：</label>
							<input type="number" name="tlCuhl" class="form_row_input" placeholder="请输入"/>
						</view>
						
						<view class="uni-form-item uni-column form_row">
							<label class="form_row_lable">铜粒铜吸收率%：</label>
							<input type="number" name="tlCuxsl" class="form_row_input" placeholder="请输入"/>
						</view>
						
						<view class="uni-form-item uni-column form_row">
							<label class="form_row_lable">锡粒锡含量%：</label>
							<input type="number" name="xlSnhl" class="form_row_input" placeholder="请输入"/>
						</view>
						<view class="uni-form-item uni-column form_row" >
							<label  class="form_row_lable">锡粒锡吸收率%：</label>
							<input type="number" name="xlSnxsl" class="form_row_input" placeholder="请输入"/>
						</view>
						
						<view class="uni-form-item uni-column form_row">
							<label class="form_row_lable">锰铁含锰量%：</label>
							<input type="number" name="mtMnhl" class="form_row_input" placeholder="请输入"/>
						</view>
						
						<view class="uni-form-item uni-column form_row">
							<label class="form_row_lable">锰铁锰吸收率%：</label>
							<input type="number" name="mtMnxsl" class="form_row_input" placeholder="请输入"/>
						</view>
							
						
						<view class="uni-form-item uni-column form_row_btn">
							<button form-type="reset" size="mini" class="reset_btn" >清空</button>
							<button form-type="submit" size="mini" class="submit_btn" >提交</button>
						</view>
					</view>
			</form>
		</view>
	</view>
</template>

<script>
	import configService from '@/common/config.service.js';
	const apiUrl = configService.apiUrl;
	export default {
		data() {
			return {
				fromData: {
				},
				model : {// 页面模型对象
					deptId:uni.getStorageSync("deptId"),
					type: 2
				},
			}
		},
		methods: {

			submit(e) {
				this.fromData = e.detail.value;
				if(Object.values(this.fromData).some(value => value === "")){
					uni.showToast({
						title: "请维护所有元素标准！",
						icon:'error',
						duration:1000
					});
					return ;
				}
				uni.showLoading({
				      title: '添加中...'
				});
				uni.request({
					url:apiUrl + '/bnhjcftzss/add', 
					data : {...this.fromData,...this.model},
					header: {
						 'Content-Type': 'application/json' //自定义请求头信息
					},
					method:'POST',//请求方式，必须为大写
					success: (res) => {
						let re = res.data;
						if(re.code == 200){
							uni.hideLoading();
							uni.showToast({
								title: '成功',
								icon:'success',
								duration:500
							});
							setTimeout(() => {
								//uni.navigateBack()//默认delta:1 方法上一页，优点：地址栏参数还是原先的。
									// uni.navigateBack({
									// 	delta : 2,//返回层数，2则上上页
									// })
								uni.redirectTo({
								    url:'/pages/bzwh/bnhjcftzlist'
								});
							}, 1000)
							
						}
					}
				 })
			},
			formReset(){
			}
		}
	}

</script>

<style scoped lang="scss">
	@import url("@/common/addEdit.css");

</style>

